package com.skplanet.oneplusonewindow.moimserver.domain;

import java.io.Serializable;
import java.text.DateFormat;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(name = "MOIM_COMMENT")
public class Moim_Comment implements Serializable{

	private static final long serialVersionUID = -909322011332867664L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	
	@Column(name = "memberId")
	private Long memberId;
	
	@Column(name = "content")
	@Type(type="text")
	private String content;
	
	@Column(name = "regdate")
	private String regdate;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "board_id")
	@JsonIgnore
	private Moim_Board board;
	
	public Moim_Comment(){
		Date date = new Date();
		DateFormat format1 = DateFormat.getDateInstance(DateFormat.MEDIUM);
		setRegdate(format1.format(date));
	}

	public Long getMemberId() {
		return memberId;
	}

	public void setMemberId(Long memberId) {
		this.memberId = memberId;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getContent() {
		return content.replaceAll("\n", "<br/>");
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getRegdate() {
		return regdate;
	}

	public void setRegdate(String regdate) {
		this.regdate = regdate;
	}
	
	

	public Moim_Board getBoard() {
		return board;
	}

	public void setBoard(Moim_Board board) {
		this.board = board;
	}

}
